

<!DOCTYPE html>
<html class="writer-html5" lang="zh" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>核心API &mdash; Scrapy 2.3.0 文档</title>
  

  
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/tooltipster.custom.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/tooltipster.bundle.min.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/tooltipster-sideTip-shadow.min.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/tooltipster-sideTip-punk.min.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/tooltipster-sideTip-noir.min.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/tooltipster-sideTip-light.min.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/tooltipster-sideTip-borderless.min.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/micromodal.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/sphinx_rtd_theme.css" type="text/css" />

  
  
  
  

  
  <!--[if lt IE 9]>
    <script src="../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/language_data.js"></script>
        <script src="../_static/js/hoverxref.js"></script>
        <script src="../_static/js/tooltipster.bundle.min.js"></script>
        <script src="../_static/js/micromodal.min.js"></script>
    
    <script type="text/javascript" src="../_static/js/theme.js"></script>

    
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" />
    <link rel="next" title="信号" href="signals.html" />
    <link rel="prev" title="扩展" href="extensions.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../index.html" class="icon icon-home" alt="Documentation Home"> Scrapy
          

          
          </a>

          
            
            
              <div class="version">
                2.3
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">第一步</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../intro/overview.html">Scrapy一目了然</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/install.html">安装指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/tutorial.html">Scrapy 教程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/examples.html">实例</a></li>
</ul>
<p class="caption"><span class="caption-text">基本概念</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="commands.html">命令行工具</a></li>
<li class="toctree-l1"><a class="reference internal" href="spiders.html">蜘蛛</a></li>
<li class="toctree-l1"><a class="reference internal" href="selectors.html">选择器</a></li>
<li class="toctree-l1"><a class="reference internal" href="items.html">项目</a></li>
<li class="toctree-l1"><a class="reference internal" href="loaders.html">项目加载器</a></li>
<li class="toctree-l1"><a class="reference internal" href="shell.html">Scrapy shell</a></li>
<li class="toctree-l1"><a class="reference internal" href="item-pipeline.html">项目管道</a></li>
<li class="toctree-l1"><a class="reference internal" href="feed-exports.html">Feed 导出</a></li>
<li class="toctree-l1"><a class="reference internal" href="request-response.html">请求和响应</a></li>
<li class="toctree-l1"><a class="reference internal" href="link-extractors.html">链接提取器</a></li>
<li class="toctree-l1"><a class="reference internal" href="settings.html">设置</a></li>
<li class="toctree-l1"><a class="reference internal" href="exceptions.html">例外情况</a></li>
</ul>
<p class="caption"><span class="caption-text">内置服务</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="logging.html">登录</a></li>
<li class="toctree-l1"><a class="reference internal" href="stats.html">统计数据集合</a></li>
<li class="toctree-l1"><a class="reference internal" href="email.html">发送电子邮件</a></li>
<li class="toctree-l1"><a class="reference internal" href="telnetconsole.html">远程登录控制台</a></li>
<li class="toctree-l1"><a class="reference internal" href="webservice.html">Web服务</a></li>
</ul>
<p class="caption"><span class="caption-text">解决具体问题</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../faq.html">常见问题</a></li>
<li class="toctree-l1"><a class="reference internal" href="debug.html">调试spiders</a></li>
<li class="toctree-l1"><a class="reference internal" href="contracts.html">蜘蛛合约</a></li>
<li class="toctree-l1"><a class="reference internal" href="practices.html">常用做法</a></li>
<li class="toctree-l1"><a class="reference internal" href="broad-crawls.html">宽爬行</a></li>
<li class="toctree-l1"><a class="reference internal" href="developer-tools.html">使用浏览器的开发人员工具进行抓取</a></li>
<li class="toctree-l1"><a class="reference internal" href="dynamic-content.html">选择动态加载的内容</a></li>
<li class="toctree-l1"><a class="reference internal" href="leaks.html">调试内存泄漏</a></li>
<li class="toctree-l1"><a class="reference internal" href="media-pipeline.html">下载和处理文件和图像</a></li>
<li class="toctree-l1"><a class="reference internal" href="deploy.html">部署蜘蛛</a></li>
<li class="toctree-l1"><a class="reference internal" href="autothrottle.html">AutoThrottle 扩展</a></li>
<li class="toctree-l1"><a class="reference internal" href="benchmarking.html">标杆管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="jobs.html">作业：暂停和恢复爬行</a></li>
<li class="toctree-l1"><a class="reference internal" href="coroutines.html">协同程序</a></li>
<li class="toctree-l1"><a class="reference internal" href="asyncio.html">asyncio</a></li>
</ul>
<p class="caption"><span class="caption-text">扩展Scrapy</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="architecture.html">体系结构概述</a></li>
<li class="toctree-l1"><a class="reference internal" href="downloader-middleware.html">下载器中间件</a></li>
<li class="toctree-l1"><a class="reference internal" href="spider-middleware.html">蜘蛛中间件</a></li>
<li class="toctree-l1"><a class="reference internal" href="extensions.html">扩展</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">核心API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#crawler-api">爬虫API</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-scrapy.settings">设置API</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-scrapy.spiderloader">SpiderLoader API</a></li>
<li class="toctree-l2"><a class="reference internal" href="#signals-api">信号API</a></li>
<li class="toctree-l2"><a class="reference internal" href="#stats-collector-api">统计收集器API</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="signals.html">信号</a></li>
<li class="toctree-l1"><a class="reference internal" href="exporters.html">条目导出器</a></li>
</ul>
<p class="caption"><span class="caption-text">其余所有</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../news.html">发行说明</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">为 Scrapy 贡献</a></li>
<li class="toctree-l1"><a class="reference internal" href="../versioning.html">版本控制和API稳定性</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">Scrapy</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
        
      <li>核心API</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="core-api">
<span id="topics-api"></span><h1>核心API<a class="headerlink" href="#core-api" title="永久链接至标题">¶</a></h1>
<p>本节记录了Scrapy核心API，它是为扩展和中间件的开发人员设计的。</p>
<div class="section" id="crawler-api">
<span id="topics-api-crawler"></span><h2>爬虫API<a class="headerlink" href="#crawler-api" title="永久链接至标题">¶</a></h2>
<p>Scrapy API的主要入口点是 <a class="reference internal" href="#scrapy.crawler.Crawler" title="scrapy.crawler.Crawler"><code class="xref py py-class docutils literal notranslate"><span class="pre">Crawler</span></code></a> 对象，通过 <code class="docutils literal notranslate"><span class="pre">from_crawler</span></code> 类方法。这个对象提供对所有Scrapy核心组件的访问，它是扩展访问它们并将其功能连接到Scrapy的唯一方法。</p><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-1466963416408457"
     data-ad-slot="8850786025"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<span class="target" id="module-scrapy.crawler"></span><p>扩展管理器负责加载和跟踪已安装的扩展，并通过 <a class="reference internal" href="settings.html#std-setting-EXTENSIONS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">EXTENSIONS</span></code></a> 包含所有可用扩展名及其顺序的字典的设置，类似于 <a class="reference internal" href="downloader-middleware.html#topics-downloader-middleware-setting"><span class="std std-ref">configure the downloader middlewares</span></a> .</p>
<dl class="py class">
<dt id="scrapy.crawler.Crawler">
<em class="property">class </em><code class="sig-prename descclassname">scrapy.crawler.</code><code class="sig-name descname">Crawler</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">spidercls</span></em>, <em class="sig-param"><span class="n">settings</span></em><span class="sig-paren">)</span><a class="headerlink" href="#scrapy.crawler.Crawler" title="永久链接至目标">¶</a></dt>
<dd><p>爬虫对象必须用 <a class="reference internal" href="spiders.html#scrapy.spiders.Spider" title="scrapy.spiders.Spider"><code class="xref py py-class docutils literal notranslate"><span class="pre">scrapy.spiders.Spider</span></code></a> 子类和A <a class="reference internal" href="#scrapy.settings.Settings" title="scrapy.settings.Settings"><code class="xref py py-class docutils literal notranslate"><span class="pre">scrapy.settings.Settings</span></code></a> 对象。</p>
<dl class="py attribute">
<dt id="scrapy.crawler.Crawler.settings">
<code class="sig-name descname">settings</code><a class="headerlink" href="#scrapy.crawler.Crawler.settings" title="永久链接至目标">¶</a></dt>
<dd><p>此爬网程序的设置管理器。</p>
<p>这被扩展和中间软件用来访问这个爬虫程序的  Scrapy   设置。</p>
<p>有关碎屑设置的介绍，请参见 <a class="reference internal" href="settings.html#topics-settings"><span class="std std-ref">设置</span></a> .</p>
<p>对于API见 <a class="reference internal" href="#scrapy.settings.Settings" title="scrapy.settings.Settings"><code class="xref py py-class docutils literal notranslate"><span class="pre">Settings</span></code></a> 班级。</p>
</dd></dl>

<dl class="py attribute">
<dt id="scrapy.crawler.Crawler.signals">
<code class="sig-name descname">signals</code><a class="headerlink" href="#scrapy.crawler.Crawler.signals" title="永久链接至目标">¶</a></dt>
<dd><p>这个爬虫的信号管理器。</p>
<p>这被扩展和中间商用来将自己连接到零碎的功能中。</p>
<p>有关信号的介绍，请参见 <a class="reference internal" href="signals.html#topics-signals"><span class="std std-ref">信号</span></a> .</p>
<p>对于API见 <code class="xref py py-class docutils literal notranslate"><span class="pre">SignalManager</span></code> 班级。</p>
</dd></dl>

<dl class="py attribute">
<dt id="scrapy.crawler.Crawler.stats">
<code class="sig-name descname">stats</code><a class="headerlink" href="#scrapy.crawler.Crawler.stats" title="永久链接至目标">¶</a></dt>
<dd><p>这个爬虫的统计收集程序。</p>
<p>这用于从扩展和中间软件记录其行为的统计信息，或访问由其他扩展收集的统计信息。</p>
<p>有关stats集合的介绍，请参见 <a class="reference internal" href="stats.html#topics-stats"><span class="std std-ref">统计数据集合</span></a> .</p>
<p>对于API见 <a class="reference internal" href="#scrapy.statscollectors.StatsCollector" title="scrapy.statscollectors.StatsCollector"><code class="xref py py-class docutils literal notranslate"><span class="pre">StatsCollector</span></code></a> 班级。</p>
</dd></dl>

<dl class="py attribute">
<dt id="scrapy.crawler.Crawler.extensions">
<code class="sig-name descname">extensions</code><a class="headerlink" href="#scrapy.crawler.Crawler.extensions" title="永久链接至目标">¶</a></dt>
<dd><p>跟踪已启用扩展的扩展管理器。</p>
<p>大多数扩展不需要访问这个属性。</p>
<p>有关扩展名的介绍和scrapy上可用扩展名的列表，请参见 <a class="reference internal" href="extensions.html#topics-extensions"><span class="std std-ref">扩展</span></a> .</p>
</dd></dl>

<dl class="py attribute">
<dt id="scrapy.crawler.Crawler.engine">
<code class="sig-name descname">engine</code><a class="headerlink" href="#scrapy.crawler.Crawler.engine" title="永久链接至目标">¶</a></dt>
<dd><p>执行引擎，它协调调度程序、下载程序和spider之间的核心爬行逻辑。</p>
<p>有些扩展可能希望访问scrapy引擎，检查或修改下载程序和调度程序的行为，尽管这是一种高级用法，而且这个API还不稳定。</p>
</dd></dl>

<dl class="py attribute">
<dt id="scrapy.crawler.Crawler.spider">
<code class="sig-name descname">spider</code><a class="headerlink" href="#scrapy.crawler.Crawler.spider" title="永久链接至目标">¶</a></dt>
<dd><p>蜘蛛当前正在被爬行。这是构建爬虫程序时提供的蜘蛛类的实例，它是在 <a class="reference internal" href="#scrapy.crawler.Crawler.crawl" title="scrapy.crawler.Crawler.crawl"><code class="xref py py-meth docutils literal notranslate"><span class="pre">crawl()</span></code></a> 方法。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.crawler.Crawler.crawl">
<code class="sig-name descname">crawl</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="headerlink" href="#scrapy.crawler.Crawler.crawl" title="永久链接至目标">¶</a></dt>
<dd><p>通过用给定的 <code class="docutils literal notranslate"><span class="pre">args</span></code> 和 <code class="docutils literal notranslate"><span class="pre">kwargs</span></code> 参数，同时设置运行中的执行引擎。</p>
<p>返回在爬网完成时激发的延迟。</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-scrapy.settings">
<span id="settings-api"></span><span id="topics-api-settings"></span><h2>设置API<a class="headerlink" href="#module-scrapy.settings" title="永久链接至标题">¶</a></h2>
<dl class="py attribute">
<dt id="scrapy.settings.SETTINGS_PRIORITIES">
<code class="sig-prename descclassname">scrapy.settings.</code><code class="sig-name descname">SETTINGS_PRIORITIES</code><a class="headerlink" href="#scrapy.settings.SETTINGS_PRIORITIES" title="永久链接至目标">¶</a></dt>
<dd><p>设置Scrapy中使用的默认设置优先级的键名称和优先级级别的字典。</p>
<p>每个项目定义一个设置入口点，为其提供标识代码名和整数优先级。在 <a class="reference internal" href="#scrapy.settings.Settings" title="scrapy.settings.Settings"><code class="xref py py-class docutils literal notranslate"><span class="pre">Settings</span></code></a> 班级。</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">SETTINGS_PRIORITIES</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s1">&#39;default&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
    <span class="s1">&#39;command&#39;</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span>
    <span class="s1">&#39;project&#39;</span><span class="p">:</span> <span class="mi">20</span><span class="p">,</span>
    <span class="s1">&#39;spider&#39;</span><span class="p">:</span> <span class="mi">30</span><span class="p">,</span>
    <span class="s1">&#39;cmdline&#39;</span><span class="p">:</span> <span class="mi">40</span><span class="p">,</span>
<span class="p">}</span>
</pre></div>
</div>
<p>有关每个设置源的详细说明，请参阅： <a class="reference internal" href="settings.html#topics-settings"><span class="std std-ref">设置</span></a> .</p>
</dd></dl>

<dl class="py function">
<dt id="scrapy.settings.get_settings_priority">
<code class="sig-prename descclassname">scrapy.settings.</code><code class="sig-name descname">get_settings_priority</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">priority</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#get_settings_priority"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.get_settings_priority" title="永久链接至目标">¶</a></dt>
<dd><p>在中查找给定字符串优先级的小助手函数 <a class="reference internal" href="#scrapy.settings.SETTINGS_PRIORITIES" title="scrapy.settings.SETTINGS_PRIORITIES"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SETTINGS_PRIORITIES</span></code></a> 并返回其数值，或直接返回给定的数值优先级。</p>
</dd></dl>

<dl class="py class">
<dt id="scrapy.settings.Settings">
<em class="property">class </em><code class="sig-prename descclassname">scrapy.settings.</code><code class="sig-name descname">Settings</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">values</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">priority</span><span class="o">=</span><span class="default_value">'project'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#Settings"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.Settings" title="永久链接至目标">¶</a></dt>
<dd><p>基类：<a class="reference internal" href="#scrapy.settings.BaseSettings" title="scrapy.settings.BaseSettings"><code class="xref py py-class docutils literal notranslate"><span class="pre">scrapy.settings.BaseSettings</span></code></a></p>
<p>此对象存储内部组件配置的  Scrapy   设置，并可用于任何进一步的自定义。</p>
<p>它是一个直接的子类，支持 <a class="reference internal" href="#scrapy.settings.BaseSettings" title="scrapy.settings.BaseSettings"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseSettings</span></code></a> . 另外，在实例化这个类之后，新对象将具有上面描述的全局默认设置 <a class="reference internal" href="settings.html#topics-settings-ref"><span class="std std-ref">内置设置参考</span></a> 已经填充。</p>
</dd></dl>

<dl class="py class">
<dt id="scrapy.settings.BaseSettings">
<em class="property">class </em><code class="sig-prename descclassname">scrapy.settings.</code><code class="sig-name descname">BaseSettings</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">values</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">priority</span><span class="o">=</span><span class="default_value">'project'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings" title="永久链接至目标">¶</a></dt>
<dd><p>此类的实例的行为类似于字典，但将优先级与其 <code class="docutils literal notranslate"><span class="pre">(key,</span> <span class="pre">value)</span></code> 对，并且可以冻结（即标记为不可变）。</p>
<p>键值项可以在初始化时通过 <code class="docutils literal notranslate"><span class="pre">values</span></code> 他们会接受 <code class="docutils literal notranslate"><span class="pre">priority</span></code> 水平（除非 <code class="docutils literal notranslate"><span class="pre">values</span></code> 已经是的实例 <a class="reference internal" href="#scrapy.settings.BaseSettings" title="scrapy.settings.BaseSettings"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseSettings</span></code></a> 在这种情况下，将保留现有的优先级）。如果 <code class="docutils literal notranslate"><span class="pre">priority</span></code> 参数是字符串，优先级名称将在 <a class="reference internal" href="#scrapy.settings.SETTINGS_PRIORITIES" title="scrapy.settings.SETTINGS_PRIORITIES"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SETTINGS_PRIORITIES</span></code></a> . 否则，应提供特定的整数。</p>
<p>创建对象后，可以使用 <a class="reference internal" href="#scrapy.settings.BaseSettings.set" title="scrapy.settings.BaseSettings.set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code></a> 方法，并且可以使用字典的方括号符号或 <a class="reference internal" href="#scrapy.settings.BaseSettings.get" title="scrapy.settings.BaseSettings.get"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get()</span></code></a> 实例的方法及其值转换变量。请求存储的密钥时，将检索具有最高优先级的值。</p>
<dl class="py method">
<dt id="scrapy.settings.BaseSettings.copy">
<code class="sig-name descname">copy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.copy"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.copy" title="永久链接至目标">¶</a></dt>
<dd><p>对当前设置进行深度复制。</p>
<p>此方法返回 <a class="reference internal" href="#scrapy.settings.Settings" title="scrapy.settings.Settings"><code class="xref py py-class docutils literal notranslate"><span class="pre">Settings</span></code></a> 类，使用相同的值及其优先级填充。</p>
<p>对新对象的修改不会反映在原始设置上。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.copy_to_dict">
<code class="sig-name descname">copy_to_dict</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.copy_to_dict"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.copy_to_dict" title="永久链接至目标">¶</a></dt>
<dd><p>复制当前设置并转换为dict。</p>
<p>此方法返回一个新的dict，该dict使用与当前设置相同的值及其优先级填充。</p>
<p>对返回的dict的修改不会反映在原始设置上。</p>
<p>例如，此方法对于在Scrapy Shell中打印设置很有用。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.freeze">
<code class="sig-name descname">freeze</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.freeze"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.freeze" title="永久链接至目标">¶</a></dt>
<dd><p>禁用对当前设置的进一步更改。</p>
<p>调用此方法后，设置的当前状态将变为不可变。尝试通过 <a class="reference internal" href="#scrapy.settings.BaseSettings.set" title="scrapy.settings.BaseSettings.set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code></a> 方法及其变体是不可能的，将被警告。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.frozencopy">
<code class="sig-name descname">frozencopy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.frozencopy"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.frozencopy" title="永久链接至目标">¶</a></dt>
<dd><p>返回当前设置的不可变副本。</p>
<p>A的别名 <a class="reference internal" href="#scrapy.settings.BaseSettings.freeze" title="scrapy.settings.BaseSettings.freeze"><code class="xref py py-meth docutils literal notranslate"><span class="pre">freeze()</span></code></a> 调用返回的对象 <a class="reference internal" href="#scrapy.settings.BaseSettings.copy" title="scrapy.settings.BaseSettings.copy"><code class="xref py py-meth docutils literal notranslate"><span class="pre">copy()</span></code></a> .</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.get">
<code class="sig-name descname">get</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em>, <em class="sig-param"><span class="n">default</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.get"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.get" title="永久链接至目标">¶</a></dt>
<dd><p>在不影响其原始类型的情况下获取设置值。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a>) -- 设置名称</p></li>
<li><p><strong>default</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(在 Python v3.9)"><em>object</em></a>) -- 如果找不到设置，则返回的值</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.getbool">
<code class="sig-name descname">getbool</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em>, <em class="sig-param"><span class="n">default</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.getbool"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.getbool" title="永久链接至目标">¶</a></dt>
<dd><p>获取设置值作为布尔值。</p>
<p><code class="docutils literal notranslate"><span class="pre">1</span></code> ， <code class="docutils literal notranslate"><span class="pre">'1'</span></code> ， <cite>True</cite> ‘和 <code class="docutils literal notranslate"><span class="pre">'True'</span></code> 返回 <code class="docutils literal notranslate"><span class="pre">True</span></code> ，同时 <code class="docutils literal notranslate"><span class="pre">0</span></code> ， <code class="docutils literal notranslate"><span class="pre">'0'</span></code> ， <code class="docutils literal notranslate"><span class="pre">False</span></code> ， <code class="docutils literal notranslate"><span class="pre">'False'</span></code> 和 <code class="docutils literal notranslate"><span class="pre">None</span></code> 返回 <code class="docutils literal notranslate"><span class="pre">False</span></code> .</p>
<p>例如，通过设置为的环境变量填充的设置 <code class="docutils literal notranslate"><span class="pre">'0'</span></code> 将返回 <code class="docutils literal notranslate"><span class="pre">False</span></code> 使用此方法时。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a>) -- 设置名称</p></li>
<li><p><strong>default</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(在 Python v3.9)"><em>object</em></a>) -- 如果找不到设置，则返回的值</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.getdict">
<code class="sig-name descname">getdict</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em>, <em class="sig-param"><span class="n">default</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.getdict"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.getdict" title="永久链接至目标">¶</a></dt>
<dd><p>获取一个设置值作为字典。如果设置原始类型为字典，则返回其副本。如果它是一个字符串，它将作为JSON字典进行计算。如果它是一个 <a class="reference internal" href="#scrapy.settings.BaseSettings" title="scrapy.settings.BaseSettings"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseSettings</span></code></a> 实例本身，它将被转换为一个字典，其中包含所有当前设置值，这些值将由返回 <a class="reference internal" href="#scrapy.settings.BaseSettings.get" title="scrapy.settings.BaseSettings.get"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get()</span></code></a> 以及丢失有关优先级和可变性的所有信息。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a>) -- 设置名称</p></li>
<li><p><strong>default</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(在 Python v3.9)"><em>object</em></a>) -- 如果找不到设置，则返回的值</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.getfloat">
<code class="sig-name descname">getfloat</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em>, <em class="sig-param"><span class="n">default</span><span class="o">=</span><span class="default_value">0.0</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.getfloat"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.getfloat" title="永久链接至目标">¶</a></dt>
<dd><p>以浮点形式获取设置值。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a>) -- 设置名称</p></li>
<li><p><strong>default</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(在 Python v3.9)"><em>object</em></a>) -- 如果找不到设置，则返回的值</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.getint">
<code class="sig-name descname">getint</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em>, <em class="sig-param"><span class="n">default</span><span class="o">=</span><span class="default_value">0</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.getint"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.getint" title="永久链接至目标">¶</a></dt>
<dd><p>以int形式获取设置值。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a>) -- 设置名称</p></li>
<li><p><strong>default</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(在 Python v3.9)"><em>object</em></a>) -- 如果找不到设置，则返回的值</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.getlist">
<code class="sig-name descname">getlist</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em>, <em class="sig-param"><span class="n">default</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.getlist"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.getlist" title="永久链接至目标">¶</a></dt>
<dd><p>以列表形式获取设置值。如果设置的原始类型是列表，则将返回其副本。如果是一个字符串，它将被“，”拆分。</p>
<p>例如，通过设置为的环境变量填充的设置 <code class="docutils literal notranslate"><span class="pre">'one,two'</span></code> 将返回列表 [一个，两个] 使用此方法时。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a>) -- 设置名称</p></li>
<li><p><strong>default</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(在 Python v3.9)"><em>object</em></a>) -- 如果找不到设置，则返回的值</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.getpriority">
<code class="sig-name descname">getpriority</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.getpriority"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.getpriority" title="永久链接至目标">¶</a></dt>
<dd><p>返回设置的当前数字优先级值，或 <code class="docutils literal notranslate"><span class="pre">None</span></code> 如果给定 <code class="docutils literal notranslate"><span class="pre">name</span></code> 不存在。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a>) -- 设置名称</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.getwithbase">
<code class="sig-name descname">getwithbase</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.getwithbase"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.getwithbase" title="永久链接至目标">¶</a></dt>
<dd><p>获取类似字典的设置及其 <cite>_BASE</cite> 对应的。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a>) -- 类似字典的设置的名称</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.maxpriority">
<code class="sig-name descname">maxpriority</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.maxpriority"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.maxpriority" title="永久链接至目标">¶</a></dt>
<dd><p>返回所有设置中存在的最高优先级的数值，或返回 <code class="docutils literal notranslate"><span class="pre">default</span></code> 从 <a class="reference internal" href="#scrapy.settings.SETTINGS_PRIORITIES" title="scrapy.settings.SETTINGS_PRIORITIES"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SETTINGS_PRIORITIES</span></code></a> 如果没有存储设置。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.set">
<code class="sig-name descname">set</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em>, <em class="sig-param"><span class="n">value</span></em>, <em class="sig-param"><span class="n">priority</span><span class="o">=</span><span class="default_value">'project'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.set"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.set" title="永久链接至目标">¶</a></dt>
<dd><p>存储具有给定优先级的键/值属性。</p>
<p>应填充设置 <em>之前</em> 配置爬虫对象（通过 <code class="xref py py-meth docutils literal notranslate"><span class="pre">configure()</span></code> 方法），否则它们不会有任何效果。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a>) -- 设置名称</p></li>
<li><p><strong>value</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(在 Python v3.9)"><em>object</em></a>) -- 要与设置关联的值</p></li>
<li><p><strong>priority</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.9)"><em>int</em></a>) -- 设置的优先级。应该是 <a class="reference internal" href="#scrapy.settings.SETTINGS_PRIORITIES" title="scrapy.settings.SETTINGS_PRIORITIES"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SETTINGS_PRIORITIES</span></code></a> 或整数</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.setmodule">
<code class="sig-name descname">setmodule</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">module</span></em>, <em class="sig-param"><span class="n">priority</span><span class="o">=</span><span class="default_value">'project'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.setmodule"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.setmodule" title="永久链接至目标">¶</a></dt>
<dd><p>存储具有给定优先级的模块的设置。</p>
<p>这是一个调用 <a class="reference internal" href="#scrapy.settings.BaseSettings.set" title="scrapy.settings.BaseSettings.set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code></a> 对于每个全局声明的大写变量 <code class="docutils literal notranslate"><span class="pre">module</span></code> 提供的 <code class="docutils literal notranslate"><span class="pre">priority</span></code> .</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>module</strong> (<a class="reference external" href="https://docs.python.org/3/library/types.html#types.ModuleType" title="(在 Python v3.9)"><em>types.ModuleType</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a>) -- 模块或模块路径</p></li>
<li><p><strong>priority</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.9)"><em>int</em></a>) -- 设置的优先级。应该是 <a class="reference internal" href="#scrapy.settings.SETTINGS_PRIORITIES" title="scrapy.settings.SETTINGS_PRIORITIES"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SETTINGS_PRIORITIES</span></code></a> 或整数</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="scrapy.settings.BaseSettings.update">
<code class="sig-name descname">update</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">values</span></em>, <em class="sig-param"><span class="n">priority</span><span class="o">=</span><span class="default_value">'project'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/settings.html#BaseSettings.update"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.settings.BaseSettings.update" title="永久链接至目标">¶</a></dt>
<dd><p>存储具有给定优先级的键/值对。</p>
<p>这是一个调用 <a class="reference internal" href="#scrapy.settings.BaseSettings.set" title="scrapy.settings.BaseSettings.set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code></a> 每一项 <code class="docutils literal notranslate"><span class="pre">values</span></code> 提供的 <code class="docutils literal notranslate"><span class="pre">priority</span></code> .</p>
<p>如果 <code class="docutils literal notranslate"><span class="pre">values</span></code> 是一个字符串，它被假定为JSON编码并被解析为一个dict <code class="docutils literal notranslate"><span class="pre">json.loads()</span></code> 第一。如果是 <a class="reference internal" href="#scrapy.settings.BaseSettings" title="scrapy.settings.BaseSettings"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseSettings</span></code></a> 例如，每个键的优先级将被使用，并且 <code class="docutils literal notranslate"><span class="pre">priority</span></code> 参数被忽略。这允许使用单个命令插入/更新具有不同优先级的设置。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>values</strong> (dict or string or <a class="reference internal" href="#scrapy.settings.BaseSettings" title="scrapy.settings.BaseSettings"><code class="xref py py-class docutils literal notranslate"><span class="pre">BaseSettings</span></code></a>) -- 设置名称和值</p></li>
<li><p><strong>priority</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.9)"><em>int</em></a>) -- 设置的优先级。应该是 <a class="reference internal" href="#scrapy.settings.SETTINGS_PRIORITIES" title="scrapy.settings.SETTINGS_PRIORITIES"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SETTINGS_PRIORITIES</span></code></a> 或整数</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-scrapy.spiderloader">
<span id="spiderloader-api"></span><span id="topics-api-spiderloader"></span><h2>SpiderLoader API<a class="headerlink" href="#module-scrapy.spiderloader" title="永久链接至标题">¶</a></h2>
<dl class="py class">
<dt id="scrapy.spiderloader.SpiderLoader">
<em class="property">class </em><code class="sig-prename descclassname">scrapy.spiderloader.</code><code class="sig-name descname">SpiderLoader</code><a class="reference internal" href="../_modules/scrapy/spiderloader.html#SpiderLoader"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.spiderloader.SpiderLoader" title="永久链接至目标">¶</a></dt>
<dd><p>这个类负责检索和处理整个项目中定义的蜘蛛类。</p>
<p>通过在 <a class="reference internal" href="settings.html#std-setting-SPIDER_LOADER_CLASS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">SPIDER_LOADER_CLASS</span></code></a> 项目设置。他们必须全面实施 <code class="xref py py-class docutils literal notranslate"><span class="pre">scrapy.interfaces.ISpiderLoader</span></code> 保证无误执行的接口。</p>
<dl class="py method">
<dt id="scrapy.spiderloader.SpiderLoader.from_settings">
<code class="sig-name descname">from_settings</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">settings</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/spiderloader.html#SpiderLoader.from_settings"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.spiderloader.SpiderLoader.from_settings" title="永久链接至目标">¶</a></dt>
<dd><p>Scrapy使用该类方法创建该类的实例。它使用当前的项目设置调用，并加载在 <a class="reference internal" href="settings.html#std-setting-SPIDER_MODULES"><code class="xref std std-setting docutils literal notranslate"><span class="pre">SPIDER_MODULES</span></code></a> 设置。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>settings</strong> (<a class="reference internal" href="#scrapy.settings.Settings" title="scrapy.settings.Settings"><code class="xref py py-class docutils literal notranslate"><span class="pre">Settings</span></code></a> instance) -- 项目设置</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="scrapy.spiderloader.SpiderLoader.load">
<code class="sig-name descname">load</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">spider_name</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/spiderloader.html#SpiderLoader.load"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.spiderloader.SpiderLoader.load" title="永久链接至目标">¶</a></dt>
<dd><p>获取具有给定名称的蜘蛛类。它将在先前加载的spider中查找具有名称的spider类 <code class="docutils literal notranslate"><span class="pre">spider_name</span></code> 如果找不到，将引发keyerror。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>spider_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.9)"><em>str</em></a>) -- 蜘蛛类名</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="scrapy.spiderloader.SpiderLoader.list">
<code class="sig-name descname">list</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/spiderloader.html#SpiderLoader.list"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.spiderloader.SpiderLoader.list" title="永久链接至目标">¶</a></dt>
<dd><p>获取项目中可用蜘蛛的名称。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.spiderloader.SpiderLoader.find_by_request">
<code class="sig-name descname">find_by_request</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">request</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/spiderloader.html#SpiderLoader.find_by_request"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.spiderloader.SpiderLoader.find_by_request" title="永久链接至目标">¶</a></dt>
<dd><p>列出能够处理给定请求的蜘蛛的名称。将尝试将请求的URL与蜘蛛的域相匹配。</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>request</strong> (<a class="reference internal" href="request-response.html#scrapy.http.Request" title="scrapy.http.Request"><code class="xref py py-class docutils literal notranslate"><span class="pre">Request</span></code></a> instance) -- 查询请求</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="signals-api">
<span id="topics-api-signals"></span><h2>信号API<a class="headerlink" href="#signals-api" title="永久链接至标题">¶</a></h2>
</div>
<div class="section" id="stats-collector-api">
<span id="topics-api-stats"></span><h2>统计收集器API<a class="headerlink" href="#stats-collector-api" title="永久链接至标题">¶</a></h2>
<p>在 <a class="reference internal" href="#module-scrapy.statscollectors" title="scrapy.statscollectors: Stats Collectors"><code class="xref py py-mod docutils literal notranslate"><span class="pre">scrapy.statscollectors</span></code></a> 模块和它们都实现由 <a class="reference internal" href="#scrapy.statscollectors.StatsCollector" title="scrapy.statscollectors.StatsCollector"><code class="xref py py-class docutils literal notranslate"><span class="pre">StatsCollector</span></code></a> 类（它们都从中继承）。</p>
<span class="target" id="module-scrapy.statscollectors"></span><dl class="py class">
<dt id="scrapy.statscollectors.StatsCollector">
<em class="property">class </em><code class="sig-prename descclassname">scrapy.statscollectors.</code><code class="sig-name descname">StatsCollector</code><a class="reference internal" href="../_modules/scrapy/statscollectors.html#StatsCollector"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.statscollectors.StatsCollector" title="永久链接至目标">¶</a></dt>
<dd><dl class="py method">
<dt id="scrapy.statscollectors.StatsCollector.get_value">
<code class="sig-name descname">get_value</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">default</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/statscollectors.html#StatsCollector.get_value"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.statscollectors.StatsCollector.get_value" title="永久链接至目标">¶</a></dt>
<dd><p>返回给定stats键的值，如果该键不存在，则返回默认值。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.statscollectors.StatsCollector.get_stats">
<code class="sig-name descname">get_stats</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/statscollectors.html#StatsCollector.get_stats"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.statscollectors.StatsCollector.get_stats" title="永久链接至目标">¶</a></dt>
<dd><p>以dict形式获取当前运行的spider的所有统计信息。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.statscollectors.StatsCollector.set_value">
<code class="sig-name descname">set_value</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">value</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/statscollectors.html#StatsCollector.set_value"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.statscollectors.StatsCollector.set_value" title="永久链接至目标">¶</a></dt>
<dd><p>为给定的stats键设置给定值。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.statscollectors.StatsCollector.set_stats">
<code class="sig-name descname">set_stats</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">stats</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/statscollectors.html#StatsCollector.set_stats"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.statscollectors.StatsCollector.set_stats" title="永久链接至目标">¶</a></dt>
<dd><p>使用传入的dict重写当前状态 <code class="docutils literal notranslate"><span class="pre">stats</span></code> 参数。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.statscollectors.StatsCollector.inc_value">
<code class="sig-name descname">inc_value</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">count</span><span class="o">=</span><span class="default_value">1</span></em>, <em class="sig-param"><span class="n">start</span><span class="o">=</span><span class="default_value">0</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/statscollectors.html#StatsCollector.inc_value"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.statscollectors.StatsCollector.inc_value" title="永久链接至目标">¶</a></dt>
<dd><p>假定给定的起始值（未设置时），按给定的计数递增给定的stats键的值。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.statscollectors.StatsCollector.max_value">
<code class="sig-name descname">max_value</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">value</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/statscollectors.html#StatsCollector.max_value"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.statscollectors.StatsCollector.max_value" title="永久链接至目标">¶</a></dt>
<dd><p>仅当同一个键的当前值小于值时，才为给定键设置给定值。如果给定键没有当前值，则始终设置该值。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.statscollectors.StatsCollector.min_value">
<code class="sig-name descname">min_value</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">value</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/statscollectors.html#StatsCollector.min_value"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.statscollectors.StatsCollector.min_value" title="永久链接至目标">¶</a></dt>
<dd><p>仅当同一键的当前值大于值时，才为给定键设置给定值。如果给定键没有当前值，则始终设置该值。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.statscollectors.StatsCollector.clear_stats">
<code class="sig-name descname">clear_stats</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/statscollectors.html#StatsCollector.clear_stats"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.statscollectors.StatsCollector.clear_stats" title="永久链接至目标">¶</a></dt>
<dd><p>清除所有统计。</p>
</dd></dl>

<p>以下方法不是stats集合API的一部分，而是在实现自定义stats收集器时使用的：</p>
<dl class="py method">
<dt id="scrapy.statscollectors.StatsCollector.open_spider">
<code class="sig-name descname">open_spider</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">spider</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/statscollectors.html#StatsCollector.open_spider"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.statscollectors.StatsCollector.open_spider" title="永久链接至目标">¶</a></dt>
<dd><p>打开给定的蜘蛛以收集统计信息。</p>
</dd></dl>

<dl class="py method">
<dt id="scrapy.statscollectors.StatsCollector.close_spider">
<code class="sig-name descname">close_spider</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">spider</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/scrapy/statscollectors.html#StatsCollector.close_spider"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#scrapy.statscollectors.StatsCollector.close_spider" title="永久链接至目标">¶</a></dt>
<dd><p>关闭给定的蜘蛛。调用之后，就不能访问或收集更多的特定统计信息。</p>
</dd></dl>

</dd></dl>

</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="signals.html" class="btn btn-neutral float-right" title="信号" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="extensions.html" class="btn btn-neutral float-left" title="扩展" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        
        &copy; 版权所有 2008–2020, Scrapy developers
      <span class="lastupdated">
        最后更新于 10月 18, 2020.
      </span>

    </p>
  </div>
    
    
    
    Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
  
 
<script type="text/javascript">
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="3.1.0";
analytics.load("8UDQfnf3cyFSTsM4YANnW5sXmgZVILbA");
analytics.page();
}}();

analytics.ready(function () {
    ga('require', 'linker');
    ga('linker:autoLink', ['scrapinghub.com', 'crawlera.com']);
});
</script>


</body>
</html>